<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('finance_shop_sub_account_bills', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('bill_id')->comment('账单id');
            $table->unsignedInteger('shop_id')->comment('店铺id');
            $table->string('shop_name')->nullable()->comment('店铺名称');
            $table->unsignedInteger('sub_account_id')->comment('子账号id');
            $table->string('sub_account')->nullable()->comment('子账号名称');
            $table->string('service_period')->nullable()->comment('子账号服务日期');
            $table->unsignedInteger('service_days')->nullable()->comment('服务天数');
            $table->string('consult_column')->nullable()->comment('平台接待数 字段');
            $table->unsignedInteger('consult_quantity')->default(0)->comment('咨询量');
            $table->string('charge_standard')->nullable()->comment('客户收费标准');
            $table->decimal('service_quote',12,1)->nullable()->comment('服务报价');
            $table->decimal('service_quote_final',12,1)->nullable()->comment('本期服务报价核算');
            $table->decimal('shop_other_fee',12,1)->nullable()->comment('店铺管理费/其他');
            $table->decimal('overtime_fee',12,1)->nullable()->comment('加班');
            $table->decimal('branch_overtime_fee',12,1)->nullable()->comment('分部加班费');
            $table->decimal('commission_fee',12,1)->nullable()->comment('提成');
            $table->decimal('turnover',12,1)->nullable()->comment('营业额');
            $table->decimal('sale_acount',12,1)->nullable()->comment('销售额');
            $table->decimal('refund_acount',12,1)->nullable()->comment('退款额');
            $table->decimal('actual_turnover',12,1)->nullable()->comment('实际营业额');
            $table->decimal('all_this_period_fee',12,1)->nullable()->comment('本期费用合计');
            $table->decimal('previous_receivable',12,1)->nullable()->comment('上期应收金额');
            $table->decimal('pdd_received',12,1)->nullable()->comment('拼多多平台已收');
            $table->decimal('previous_reserved',12,1)->nullable()->comment('上期留抵金额');
            $table->decimal('deposit_cost',12,1)->nullable()->comment('保证金抵扣');
            $table->decimal('other_received',12,1)->nullable()->comment('其他(回款项)');
            $table->decimal('all_received',12,1)->nullable()->comment('回款项之和');
            $table->decimal('customer_period_pay',12,1)->nullable()->comment('本期应收客户金额');
            $table->string('remark')->nullable()->comment('备注');
            $table->tinyInteger('data_fill_status')->default(0)->comment('数据填报状态：默认0待审核，1已审核');
            $table->unsignedInteger('customer_id')->nullable()->comment('客户id');
            $table->string('company_name')->nullable()->comment('公司名称');
            $table->string('wx_group')->nullable()->comment('微信群名称');
            $table->tinyInteger('quotation_change_status')->default(0)->comment('报价变化状态');
            $table->unsignedInteger('quotation_group_id')->default(0)->comment('报价组id');
            $table->decimal('penalty_amount',12,1)->nullable()->comment('罚款');
            $table->integer('quote_total_consult')->nullable()->comment('报价总咨询量');
            $table->integer('quote_day_average_consult')->nullable()->comment('报价日平均咨询量');
            $table->unsignedInteger('total_quote_consult_days')->default(0)->comment('天数');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `finance_shop_sub_account_bills` comment '客户账单子账号账单信息'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('finance_shop_sub_account_bills');
    }
};
